package account

import (
	"context"

	"core/contract/db"
	coreIError "core/contract/error"
	"core/enum/response"
	model "core/model/mysql"
	errorSvc "core/service/error"
)

type AddApi struct {
	DbFactory db.IDbFactory `inject:""`
}

func (a AddApi) Call(ctx context.Context) (interface{}, coreIError.IError) {
	newAccount := model.Account{
		AccountName: "hcc0000",
	}

	err := a.DbFactory.Build(ctx).Add(&newAccount)
	if err != nil {
		return nil, errorSvc.NewError(response.Fail, err)
	}

	return newAccount, nil
}
